package com.序列化;

import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.ObjectMapper;

import java.io.IOException;

public class JackSonTest {


    public static void main(String[] args) {


        SerializeTemplate serializeTemplate = new SerializeTemplate( "小明",10);

        ObjectMapper objectMapper = new ObjectMapper();
        try {

             byte[] bytes = objectMapper.writeValueAsBytes(serializeTemplate);


             String str = objectMapper.writeValueAsString(serializeTemplate);
             System.out.println(new String(bytes));
             System.out.println(str);


            SerializeTemplate serializeTemplate1 =  objectMapper.readValue(str,SerializeTemplate.class);

            System.out.println(serializeTemplate1);

        } catch (JsonProcessingException e) {
            e.printStackTrace();
        } catch (IOException e) {
            e.printStackTrace();
        }
    }
}
